#encoding=utf8
'''
Created on 2012-10-17

@author: Administrator
'''
from Processor import Processor
from pub import Func, UserDict;
from pub.Config import Config;
from models import UserModel;

class UFSClass(Processor):
    '''
    指令：UFS(user friend Search) 
    备注：搜索玩家
    格式：c-s:Cmd#cmdID#keyword
     s-c:Cmd#cmdID#result#msg#userID#userNickName#usersex#userSign#userProvince#userCity#userPhoto
    '''
    def __init__(self):
        Processor.__init__(self);
        self.__keyword = "";

        
    def dataValidtor(self, cmdContent):
        if not cmdContent:
            return False;
        paraLen = len(cmdContent);
        if paraLen == 1:      
            self.__keyword = Func.toStr(cmdContent[0]);
        
            return True;        
        return False;
    def outData(self,):
        userM=UserModel();
        user=userM.getUserInfoByKeyword(self.__keyword);
        sendData=[];
        if not user:
            sendData.append(0);
            sendData.append(Config.I_USER_FIND_INFO_ERROR);
        else:
            sendData.append(1);
            sendData.append(Config.I_USER_FIND_INFO_SUSS);
            sendData.append(user.get_user_id());
            sendData.append(user.get_user_nick_name());
            sendData.append(user.get_user_sex());
            sendData.append(user.get_user_sign());
            sendData.append(user.get_user_province());
            sendData.append(user.get_user_area());
            sendData.append(user.get_user_photo());
        Func.sendMsgStr(self._sockObj, self.setPackage(sendData));
        return True;            
        
             
